// ========================================================
// Des：
// Autor：Mr.H 
// CreateTime：2024/04/07 23:26:43
// 版 本：v 1.0
// ========================================================
using UnityEngine;


public enum E_ProType
{
    Weapon,
    HP,
    MaxHp,
    Def,
    Atk
}

public class ProReward : MonoBehaviour
{
    public E_ProType type = E_ProType.Atk;
    public int changeValue = 2;
    public GameObject getEff;//拾取特效
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            PlayerObj player = other.GetComponent<PlayerObj>();
            //根据属性来加类型
            switch (type)
            {
                case E_ProType.HP:
                    player.hp += changeValue;
                    if (player.hp > player.maxHp)
                    {
                        player.hp = player.maxHp;
                    }
                    //更新血条
                    GamePanel.Instance.UpdateHP(player.maxHp, player.hp);
                    break;
                case E_ProType.MaxHp:
                    player.maxHp += changeValue;
                    //更新血条
                    GamePanel.Instance.UpdateHP(player.maxHp, player.hp);
                    break;
                case E_ProType.Def:
                    player.def += changeValue;
                    break;
                case E_ProType.Atk:
                    player.atk += changeValue;
                    break;
            }
            GameObject eff = Instantiate(getEff, transform.position, Quaternion.identity);
            AudioSource a = eff.GetComponent<AudioSource>();
            a.volume = GameDataMgr.Instance.musicData.soundValue;
            a.mute = !GameDataMgr.Instance.musicData.isOpenSound;
            Destroy(gameObject);
        }


    }
}
